package com.mysterymall.Controller.Admin;

import com.mysterymall.Common.Comp.HttpStatus;
import com.mysterymall.Common.Comp.Log;
import com.mysterymall.Common.Utils.Result;
import com.mysterymall.Service.PaymentClassService;
import com.mysterymall.Service.PaymentService;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @ClassName com.mysterymall.Controller.Admin
 * @Description
 * @Author HuangWX
 * @Time 2023/12/18  11:44
 */
@RestController
@RequestMapping("/paymentClass")
public class AdminPaymentClassController {

    private final PaymentClassService paymentClassService;


    /**
     * 构造器注入
     * @param paymentClassService 支付服务
     */
    public AdminPaymentClassController(PaymentClassService paymentClassService) {
        this.paymentClassService = paymentClassService;
    }

    @GetMapping ("/addPaymentClass")
    @Log
    public Result addPaymentClass(@RequestParam("paymentAccount") BigDecimal paymentAccount){

        return paymentClassService.addPaymentClass(paymentAccount);
    }


    /**
     * 删除支付方式
     * @param paymentClassId 支付方式id
     * @return Result
     */
    @GetMapping("/deletePaymentClass")
    @Log
    public Result deletePaymentClass(@RequestParam("id") String paymentClassId){


        if(paymentClassId.equals("947926e8-62d2-0f0f-6527-e2d0c5414043")){
            return new Result(HttpStatus.BAD_NOT_PASS,"message.deleteError-不可删除,这个是用户自定义金额选项");
        }

        return paymentClassService.deletePaymentClass(paymentClassId);
    }

}
